import WYapi from "@/utils/request"


export interface listModel {
  moduleName: string;
  order: number;
  moduleType: string;
  moduleKey: string;
  dataComponentKey: string;
}

//导航
export interface tomatoesMdoel {
  img: string;
  link: string;
  name: string;
  order: number;
}
//轮播图
export interface adFocusPictureDetailModel {
  adId: number;
  adType: number;
  buttonShowed: boolean;
  clickAction: number;
  clickType: number;
  cover: string;
  description: string;
  displayType: number;
  isAd: boolean;
  link: string;
  name: string;
  openlinkType: number;
  realLink: string;
  targetId: number;
}

export interface focusImageModel {
  adFocusPictureDetail: adFocusPictureDetailModel;
  categoryId: number;
  clickTokens: [];
  responseId: number;
  showTokens: [];
}
//顶部导航数据
export interface navMdoel {
  moreLink: string;
  order: number;
  rankId: number;
  rankingContentInfoList: {};
  size: number;
  title: string;
}

//首页轮播导航数据
export interface moduleContentMdoel {
  focusImages: [];
  moduleRankDatas: navMdoel[];
  pictures: [];
  tomatoes: tomatoesMdoel[];
}

export interface CarouselModel {
  moduleContent: moduleContentMdoel;
  moduleKey: string;
  moduleType: string;
}

export interface CategoryModel {
  category: searchlistModel[]
}

export interface searchlistModel {
  categoryId: number,
  categoryName: string
}

//搜索列表
export interface SearchListModel {
  count: number
  display_type: number
  display_word: string
  intro: string
  is_through: boolean
  outside_hot_search_type: number
  score: number
  shift: number
  tgt_id: number
  through_type: number
  url: string
  word: string
}



export interface listModel {
  moduleName: string;
  order: number;
  moduleType: string;
  moduleKey: string;
  dataComponentKey: string;
}
// 热门推荐
export interface HotRecommendModel {
  albums: albumsModel[];
  currentUid: number;
  pageNum: number;
  pageSize: number;
  total: number;
}
// 猜你喜欢
export interface likeModel {
  albums: albumsModel[];
  currentUid: number;
  pageNum: number;
  pageSize: number;
  total: number;
}

export interface albumsModel {
  albumCoverPath: string;
  albumId: number;
  albumPlayCount: number;
  albumSubscript: number;
  albumTitle: string;
  albumTrackCount: number;
  albumUrl: string;
  albumUserNickName: string;
  anchorGrade: number;
  anchorId: number;
  anchorUrl: string;
  intro: string;
  isDeleted: boolean;
  isFinished: 1;
  isPaid: boolean;
  logoType: number;
  mvpGrade: number;
  vipType: number;
}

//导航
export interface tomatoesMdoel {

  img: string
  link: string
  name: string
  order: number
}
//轮播图
export interface adFocusPictureDetailModel {
  adId: number
  adType: number
  buttonShowed: boolean
  clickAction: number
  clickType: number
  cover: string
  description: string
  displayType: number
  isAd: boolean
  link: string
  name: string
  openlinkType: number
  realLink: string
  targetId: number
}


export interface focusImageModel {
  adFocusPictureDetail: adFocusPictureDetailModel
  categoryId: number
  clickTokens: []
  responseId: number
  showTokens: []
}
//顶部导航数据
export interface navMdoel {
  moreLink: string
  order: number
  rankId: number
  rankingContentInfoList: {}
  size: number
  title: string
}



//首页轮播导航数据
export interface moduleContentMdoel {
  focusImages: []
  moduleRankDatas: navMdoel[]
  pictures: []
  tomatoes: tomatoesMdoel[]
}


export interface CarouselModel {
  moduleContent: moduleContentMdoel
  moduleKey: string
  moduleType: string
}

export interface Model {
  context?: {}
  data: CarouselModel
  ret: number
}


// 分类数据ts类型
export interface listModel {
  moduleName: string,
  order: number,
  moduleType: string,
  moduleKey: string,
  dataComponentKey: string
}
export interface channelsModel {
  channelId: number,
  channelName: string,
  coverPath: string,
  newCount: number
  position: number
  relationMetadataValueId: number
  trackCount: number
  type: number
  subChannels: []
}
export interface groupsModel {
  text?: string,
  id: number,
  name: string,
  channelCount: number,
  position: number,
  channels: channelsModel[]
}
export interface groupsListModel {
  groups: groupsModel[],
  totalCount: 26
}
export interface classifyList {
  data: groupsListModel,
}


// 请求听单列表数据ts类型
export interface ListenListModel {
  cid: number
  name: string
  pageView: number
  title: string
}
export interface categoriesModel {
  categories: ListenListModel[]
}
export interface ListenModel {
  data: categoriesModel
}



export const getonelist = () => {
  return WYapi.get<any, listModel>(`https://m.ximalaya.com/m-revision/page/index/queryIndexTabModule`)
}
//获取顶部导航数据
export const getNavList = () => {
  return WYapi.get<any>(`/m-revision/page/index/queryIndexTabModule`)
}


//获取推荐数据
export const getCarousel = () => {
  return WYapi.get<any, Model>(`/m-revision/page/index/queryIndexTabContent?moduleKey=tuijian`)
}

//热门推荐
export const HotRecommend = () => {
  return WYapi.get<any, HotRecommendModel>(
    "/revision/category/v2/albums?pageNum=1&pageSize=6&sort=1"
  );
};

//猜你喜欢
export const likeListData = (page: number, limit: number) => {
  return WYapi.get<any, likeModel>(
    `/revision/category/v2/albums?pageNum=${page}&pageSize=${limit}&sort=2`
  );
};
// return WYapi.get<any, listModel>(`https://m.ximalaya.com/m-revision/page/index/queryIndexTabModule`)
// }

export interface SearchModel {
  hotWordResultList: SearchListModel[]
}

//获取搜索页头部数据
export const getsearchlist = () => {
  return WYapi.get<any, CategoryModel>('hotWordBillboardCategory')
}
//获取搜索页下拉列表
export const reqSearchList = (categoryId: string, size: number) => {
  return WYapi.get<any, SearchModel>(`hotWordBillboard/list/2.0?categoryId=${categoryId}&size=${size}`)
}
// 某个分类下的关键字列表 https://search.ximalaya.com/hotWordBillboard/list/2.0?categoryId=-1&size=24
export const reqkeywordList = (categoryId: number) => {
  return WYapi.get<any, SearchModel>(`hotWordBillboard/list/2.0?categoryId=${categoryId}&size=24`)
}
// 请求分类下的列表
export const getClassify = () => {
  return WYapi.get<any, classifyList>(`/revision/metadata/v2/group/all?includeChannels=true`)
}
//请求听单下的分类列表
export const getListenList = () => {
  return WYapi.get<any, ListenModel>(`/revision/subject/category`)
}
// 请求听单分类下的某个听单列表
export const getListenListNav = (name: any, pageNum: any, pageSize: any) => {
  return WYapi.get<any>(`/revision/subject/categorySubjectList/${name}?pageNum=${pageNum}&pageSize=${pageSize}`)
}
